var express = require('express');
var session = require('express-session');
var path = require('path');
var router = express.Router();
var sqlite3 = require('sqlite3').verbose();

/* GET users listing. */
router.get('/', function (req, res, next) {
  var username = req.query.username;
  var db = new sqlite3.Database(path.join(__dirname, "../db/data.s3db"));
  try {
    db.serialize(function () {
      sqlStr = "SELECT * from user where username=='" + username + "'";
      db.all(sqlStr, function (err, rows) {
        if (rows.length != 0)
          res.send('0'); //用户已存在
        else
          res.send('1');
      });
    });
  } catch (ex) {
    console.log(ex);
  }
});

module.exports = router;